import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo33 {
    public static void main(String[] args){
        //最普通的线程池  能根据任务数目自动进行线程扩容
        //ExecutorService service =  Executors.newCachedThreadPool();
        ExecutorService service =  Executors.newFixedThreadPool(10);

        for(int i = 0; i < 1000 ; i++) {
            int id = i;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello " + id+" " +Thread.currentThread().getName());
                }
            });
        }

//        //创建一个固定线程数目的线程池
//        Executors.newFixedThreadPool(4);
//        //创建一个只含有一个线程的线程池
//        Executors.newSingleThreadExecutor();
//        //创建一个固定线程数，但是任务延时执行的线程池
//        Executors.newScheduledThreadPool(4);
    }
}
